package com.theobserver.theobserver;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.avos.avoscloud.AVObject;

import java.util.ArrayList;

/**
 * Created by wssxk on 7/8/17.
 */

public class NewsColumnAdapter extends BaseAdapter {
    Context mContext = null;
    ArrayList<Column> column = null;

    public NewsColumnAdapter(Context context)
    {
        mContext = context;
        column = new ArrayList<>();
    }

    public int getCount()
    {
        return column.size();
    }

    public Object getItem(int pos)
    {
        return column.get(pos);
    }

    public long getItemId(int pos)
    {
        return pos;
    }

    public View getView(int pos, View convert, ViewGroup root)
    {
        View v = View.inflate(mContext, R.layout.news_column_item, null);

        ImageView column_cover = v.findViewById(R.id.imageview_column_cover);
        TextView column_title = v.findViewById(R.id.textview_column_title);
        column_cover.setImageBitmap(column.get(pos).cover);
        column_title.setText(column.get(pos).cur_column.getString("column_name"));
        NewsItemFrameLayout frameLayout_column =  v.findViewById(R.id.framelayout_column_item);
        frameLayout_column.column = column.get(pos);
        return v;
    }
}
